//
//  NotesDetailHeaderView.m
//  TravelFirst
//
//  Created by lanou on 15/9/21.
//  Copyright (c) 2015年 吴娅君. All rights reserved.
//

#import "NotesDetailHeaderView.h"

@implementation NotesDetailHeaderView

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        self.nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(15 * kFrameWidthScale, 15 * kFrameHeightScale, (kWidth - 30) * kFrameWidthScale, 30 * kFrameHeightScale)];
        //self.nameLabel.backgroundColor = [UIColor orangeColor];
        self.nameLabel.numberOfLines = 0;
        [self addSubview:self.nameLabel];
        
        self.locationLabel = [[UILabel alloc] initWithFrame:CGRectMake(15 * kFrameWidthScale, 50 * kFrameHeightScale, (kWidth - 30) * kFrameWidthScale, 15 * kFrameHeightScale)];
        self.locationLabel.font = [UIFont systemFontOfSize:13];
        //self.locationLabel.backgroundColor = [UIColor redColor];
        [self addSubview:self.locationLabel];
        
        self.timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(15 * kFrameWidthScale, 50 + 15 + 10 * kFrameHeightScale, (kWidth - 30) * kFrameWidthScale, 15 * kFrameHeightScale)];
        self.timeLabel.font = [UIFont systemFontOfSize:13];
        //self.timeLabel.backgroundColor = [UIColor blueColor];
        [self addSubview:self.timeLabel];
    }
    return self;
}

- (void)setValueWithModel:(NotesModel *)model
{
    self.nameLabel.text = model.name;
    CGRect frame = [self.nameLabel.text boundingRectWithSize:CGSizeMake(kWidth - 30, 1000) options:NSStringDrawingUsesLineFragmentOrigin attributes:[NSDictionary dictionaryWithObject:[UIFont systemFontOfSize:17] forKey:NSFontAttributeName] context:nil];
    self.nameLabel.frame = CGRectMake(15 * kFrameWidthScale, 15 * kFrameHeightScale, (kWidth - 30) * kFrameWidthScale, frame.size.height * kFrameHeightScale);
    if (model.destination && model.destination.length != 0) {
        self.locationLabel.text = model.destination;
        self.locationLabel.frame = CGRectMake(15 * kFrameWidthScale, (15 + frame.size.height + 5) * kFrameHeightScale, (kWidth - 30) * kFrameWidthScale, 15 * kFrameHeightScale);
        self.timeLabel.frame = CGRectMake(15 * kFrameWidthScale, (45 + frame.size.height) * kFrameHeightScale, (kWidth - 30) * kFrameWidthScale, 15 * kFrameHeightScale);
    } else {
        self.locationLabel.frame = CGRectZero;
        self.timeLabel.frame = CGRectMake(15 * kFrameWidthScale, (15 + frame.size.height + 10) * kFrameHeightScale, (kWidth - 30) * kFrameWidthScale, 15 * kFrameHeightScale);
    }
    self.timeLabel.text = [NSString stringWithFormat:@"%@ · %@天 · %@图", model.start_date, model.total_days, model.photo_number];
}

@end
